/*
 * loadDescriptor.cpp
 *
 *  Created on: Nov 6, 2012
 *      Author: robot
 */
#include <camera/camera.h>

using namespace cv;

/**
 *	Load image descriptor.
 */
void Camera::loadDescriptor ()
{
	//-- Step 1: Detect the keypoints using SURF Detector
	int minHessian = 100;
	SurfFeatureDetector detector( minHessian, 16, 8, true, true );
	//SiftFeatureDetector detector( 40, 4, 0.01, 20.0, 1.0);

	//-- Step 2: Calculate descriptors (feature vectors)
	SurfDescriptorExtractor extractor;
	//SiftDescriptorExtractor extractor;

	for (int i = 0; i < 12; i++)
	{
		char  tagname[19];
		sprintf(tagname, "tags/needle_%d.png", i);
		ROS_INFO("Loading tag %s", tagname);
		tag current;
		current.image = imread(tagname);
		if (!current.image.data)
			ROS_ERROR("Unable to load tag %d, make sure the camera node is run from /sensor!", i);
		detector.detect( current.image, current.keypoints );
		extractor.compute( current.image, current.keypoints, current.descriptor );
		ROS_INFO("Found %d keypoints", current.keypoints.size());
		tags.push_back(current);
	}
	ROS_INFO("Loaded %d tags.", tags.size());
}
